	<!-- Student_studyWindow.html -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>课堂frame</title>
		<link rel="stylesheet" type="text/css" href="../../css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/base.css"/>
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<style type="text/css" media="screen">
			.mui-table-view-cell:active {
				color: #222222;
			}
			.redPointMessage {
				top: 4px;
				left: 50px;
				display: none;
			}
			.mui-table-view .mui-media-object {
				line-height: 48px;
				max-width: 48px;
				height: 48px;
			}
			.mui-table-view-cell:active {
				color: #222222
			}
			.mui-media-body {
				color: #222222
			}
		</style>
	</head>
	<body>
		<div id="contentDiv" class="top_10">
			<ul class="mui-table-view mui-table-view-chevron base_grey base_content_font management  " >
				<li id="qiandao" class="mui-table-view-cell mui-media" onclick="jumpTo(1)" style="position:relative;">
					<a class='mui-navigate-right' href="javascript:;"> <img class="mui-media-object mui-pull-left"
					src="../../image/icon_qiandao_.png"> <div id="qd_message" class="redPointMessage"></div>
					<div class="mui-media-body base_content_font">
						签到
					</div> </a>
				</li>
				<li id="qiangda" class="mui-table-view-cell mui-media" onclick="jumpTo(2)" style="position:relative;">
					<a class='mui-navigate-right' href="javascript:;"> <img class="mui-media-object mui-pull-left"
					src="../../image/icon_qusetion.png"> <div id="tw_message" class="redPointMessage"></div>
					<div class="mui-media-body base_content_font ">
						提问
					</div> </a>
				</li>
				<li id="diaocha" class="mui-table-view-cell mui-media" onclick="jumpTo(3)" style="position:relative;">
					<a class='mui-navigate-right' href="javascript:;"> <img class="mui-media-object mui-pull-left"
					src="../../image/diaocha.png"> <div id="dc_message" class="redPointMessage"></div>
					<div class="mui-media-body base_content_font" id="research">
						调查
					</div> </a>
				</li>
				<li id="taolun" class="mui-table-view-cell mui-media" onclick="jumpTo(4)" style="position:relative;">
					<a class='mui-navigate-right' href="javascript:;"> <img class="mui-media-object mui-pull-left"
					src="../../image/taolun.png"> <div id="tl_message" class="redPointMessage"></div>
					<div class="mui-media-body base_content_font">
						讨论
					</div> </a>
				</li>
				<li id="huping" class="mui-table-view-cell mui-media" onclick="jumpTo(6)" style="position:relative;">
					<a class='mui-navigate-right' href="javascript:;"> <img class="mui-media-object mui-pull-left"
					src="../../image/icon_huping.png"> <div id="Mutual_message" class="redPointMessage" ></div>
					<div class="mui-media-body base_content_font">
						互评
					</div> </a>
				</li>
				<li id="test" class="mui-table-view-cell mui-media" onclick="jumpTo(5)" style="position:relative;">
					<a class='mui-navigate-right' href="javascript:;"> <img class="mui-media-object mui-pull-left"
					src="../../image/icon_vote.png"> <div id="vo_message" class="redPointMessage" ></div>
					<div class="mui-media-body base_content_font">
						投票
					</div> </a>
				</li>
				<li id="spontaneousMoments" class="mui-table-view-cell mui-media" onclick="jumpTo(7)" style="position:relative;">
					<a class='mui-navigate-right' href="javascript:;"> <img class="mui-media-object mui-pull-left"
					src="../../image/icon_jcsj.png"> 
					<!-- <div id="vo_message" class="redPointMessage" ></div> -->
					<div class="mui-media-body base_content_font">
						精彩瞬间
					</div> </a>
				</li>
			</ul>
		</div>
	</body>
	<script src="../../script/api.js" type="text/javascript"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script src="../../script/push.js" type="text/javascript"></script>
	<script src="../../script/common.js"></script>
	<script>
		var vo_type = "";
		var vote_iid = "";
		var vote_status = "";
		var vote_template = "1";
		var vote_userstatus = "1";
		var MutualRatingstatus = "1";
		//互评状态
		var MutualRatingstudent_status = "";
		//互评学生状态
		var MutualRatingdata = "1";
		//互评对象
		apiready = function() {
			var type = $api.getStorage('tabbarSelectedIndex');
			if (type == 0) {
				api.sendEvent({
					name : 'showCourseFrameGroupNotifi'
				});
				return;
			} else {
				api.sendEvent({
					name : 'hideCourseFrameGroupNotifi'
				});
			}
			if (type == 1) {
				api.sendEvent({
					name : 'showStudy_classNotifi'
				});
			} else {
				api.sendEvent({
					name : 'hideStudy_classNotifi'
				});
			}
			api.addEventListener({
				name : 'pushMessage_classroom_show'
			}, function(ret, err) {
				//课堂消息处理
				getMessage();
				//投票消息推送
			});
			ReceVoteNotifi();
			getMessage();
			getNewVoteMessage();
			getMutualRatingStatus();
			setRefreshHeader();
		}
		
				//下拉刷新
		function setRefreshHeader() {
			api.setRefreshHeaderInfo({
				visible : true,
				bgColor : '#ccc',
				textColor : '#fff',
				textDown : '下拉刷新...',
				textUp : '松开刷新...',
				showTime : true
			}, function(ret, err) {
				getNewVoteMessage();
			getMutualRatingStatus();
			});
		}
		//接收投票红点推送通知
		function ReceVoteNotifi() {
			api.addEventListener({
				name : 'pushMessage_classroomMessage'
			}, function(ret, err) {
				var id = ret.value.id;
				var status = ret.value.status;
				var VOTE_TYPE = ret.value.type;
				if (VOTE_TYPE == 10057) {//投票
					getNewVoteMessage()
				} else if (MUTUAL_START_TYPE == VOTE_TYPE && $api.getStorage('cfnetppjxid') == ret.value.jid) {
					getMutualRatingStatus();
				}
			});
			//学生提交投票成功后接收刷新信息，获取最新投票活动信息
			api.addEventListener({
				name : 'RefreshVoteClassList'
			}, function(ret, err) {
				getNewVoteMessage()
			});
			
			
		}

		//获取最新一条投票信息
		function getNewVoteMessage() {
			var jid = $api.getStorage('cfnetppjxid');
			var params = {
				tid : 6,
				jid : jid,
				uid : $api.getStorage('cfnetppuid'),
				rows : 1,
				cid : api.pageParam.courseid,
				pid : api.pageParam.planid,
			}
			cfnetppPOST(url_stuGetActivelist, params, false, function(data, status) {
			api.refreshHeaderLoadDone();
			api.hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						if (!isObjectEmpty(data.data)) {
							//						   activestatus 互动状态 1开启 2 是结束 3 是删除
							//                         userstatus  学生状态 1未投票 2 已投票
							vote_iid = data.data[0].iid;
							vote_status = data.data[0].activestatus;
							vote_template = data.data[0].template;
							vote_userstatus = data.data[0].userstatus;
							if (vote_status == 1) {//投票开始或者进行中
								//投票
								var vo = $api.getStorage('cfnetppmessageclassroom' + jid + VOTE_START_TYPE + vote_iid);
								if (vo == 0) {
									$("#vo_message").hide();
								} else {
									$("#vo_message").show();
								}
							} else {
								$("#vo_message").hide();
							}
						}
					} else {
						vote_iid = "";
					}
				} else {
				}
			})
		}

		//获取最新一条互评状态
		function getMutualRatingStatus() {
			showProgress();
			var params = {
				jid : $api.getStorage('cfnetppjxid'),
				uid : $api.getStorage('cfnetppuid'),
				tid : "7",
				cid : api.pageParam.courseid,
				pid : api.pageParam.planid,
			}
			//									alert(JSON.stringify(params));
			cfnetppPOST(url_getActiveStudentStatus, params, true, function(data, status) {
				//							    				alert(JSON.stringify(data));
				api.refreshHeaderLoadDone();
				api.hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						MutualRatingdata = data.data;
						MutualRatingstatus = MutualRatingdata.status;
						MutualRatingstudent_status = MutualRatingdata.student_status;
						if (MutualRatingstatus == 1 && MutualRatingstudent_status == 1) {//开始，并且未打分
							$("#Mutual_message").show();
						} else {
							$("#Mutual_message").hide();
						}
					} else {
						$("#Mutual_message").hide();
					}
				} else {
					$("#Mutual_message").hide();
				}
			})
		}

		function getMessage() {
			var type = $api.getStorage('cfnetSelectType');
			var num = 0;
			if (type != 1) {
				//读取消息推送
				var jid = $api.getStorage('cfnetppjxid');
				//签到 消息
				var qd = $api.getStorage('cfnetppmessageclassroom' + jid + QD_TYPE);
				if (qd == 1) {
					$("#qd_message").show();
				} else {
					num++;
					$("#qd_message").hide();
				}
				//调查
				var dc = $api.getStorage('cfnetppmessageclassroom' + jid + DC_TYPE);
				console.log("dc : " + dc);
				if (dc == 1) {
					$("#dc_message").show();
				} else {
					num++;
					$("#dc_message").hide();
				}
				//讨论
				var tl = $api.getStorage('cfnetppmessageclassroom' + jid + TL_TYPE);
				if (tl == 1) {
					$("#tl_message").show();
				} else {
					num++;
					$("#tl_message").hide();
				}
				//提问
				var tw = $api.getStorage('cfnetppmessageclassroom' + jid + TW_TYPE);
				if (tw == 1) {
					$("#tw_message").show();
				} else {
					num++;
					$("#tw_message").hide();
				}
				//pushMessage_classroom
				//点击课堂隐藏红点, 发送广播
				if (num == 4) {
					//课堂消息处理
					api.sendEvent({
						name : 'pushMessage_classroom_hide'
					});
				}
			}
		}

		function jumpTo(index) {
			//读取消息推送
			var jid = $api.getStorage('cfnetppjxid');
			switch (index) {
				case 1:
					{
						api.openWin({useWKWebView:true,
							name : 'Student_signedWindow_LuDong_Title',
							url : 'Student_signedWindow_LuDong_Title.html',
							pageParam : {
								cid : api.pageParam.courseid,
								pid : api.pageParam.planid,
								ismocc : api.pageParam.ismocc,
								sourceurl : window.location.pathname,
					            sourcetitle : document.title
							}
						});
					}
					break;
				case 2:
					{
						api.openWin({useWKWebView:true,
							name : 'Student_questionsWindow',
							url : 'Student_questionsWindow.html',
							pageParam : {
								cid : api.pageParam.courseid,
								pid : api.pageParam.planid,
								sourceurl : window.location.pathname,
					            sourcetitle : document.title
							}
						});
					}
					break;
				case 3:
					{
						api.openWin({useWKWebView:true,
							name : 'Student_ResearchWindow',
							url : 'Student_ResearchWindow.html',
							pageParam : {
								cid : api.pageParam.courseid,
								pid : api.pageParam.planid,
								sourceurl : window.location.pathname,
					            sourcetitle : document.title
							}
						});
					}
					break;
				case 4:
					{
						api.openWin({useWKWebView:true,
							name : 'Discuss_StudentListWin',
							url : '../Discuss/Discuss_StudentListWin.html',
							pageParam : {
								cid : api.pageParam.courseid,
								pid : api.pageParam.planid,
								sourceurl : window.location.pathname,
					            sourcetitle : document.title
							}
						});
					}
					break;
				case 5:
					{
						if (isEmpty(vote_status) || isEmpty(vote_userstatus) || (vote_userstatus == 1 && vote_status == 1) || (vote_status == 2)) {//投票未关闭,未参加投票,或者投票关闭
							api.openWin({useWKWebView:true,
								name : 'Student_VoteWindow',
								url : 'Student_VoteWindow.html',
								pageParam : {
									cid : api.pageParam.courseid,
									pid : api.pageParam.planid,
									iid : vote_iid,
									status : vote_status, //1是开始，2说进行中，3已结束
									template : vote_template,
									ismocc : api.pageParam.ismocc,
									userstatus : vote_userstatus,
									sourceurl : window.location.pathname,
					            sourcetitle : document.title
								}
							});
						} else {//投票未关闭，已参加投票
							api.openWin({useWKWebView:true,
								name : 'Student_VoteScoreWindow',
								url : 'Student_VoteScoreWindow.html',
								pageParam : {
									cid : api.pageParam.courseid,
									pid : api.pageParam.planid,
									iid : vote_iid,
									status : vote_status, //1是开始，2说进行中，3已结束
									template : vote_template,
									ismocc : api.pageParam.ismocc,
									userstatus : vote_userstatus,
									sourceurl : window.location.pathname,
					                sourcetitle : document.title
								}
							});
						}
					}
					break;
				case 6:
					{
						//					 if(MutualRatingstatus == 1&&MutualRatingstudent_status ==1){//开始，并且未打分
						//					    		api.openWin({useWKWebView:true,
						//									name : 'MutualRatingDoScoreViewWind',
						//									url : '../MutualRating/MutualRatingDoScoreViewFram.html',
						//									pageParam : {
						//										stuid : MutualRatingdata.uid,
						//										id : MutualRatingdata.id,
						//										name : MutualRatingdata.stuname,
						//										picurl : MutualRatingdata.picurl
						//									}
						//								});
						//					 }else{
						api.openWin({useWKWebView:true,
							name : 'StudentMutualRatingViewWind',
							url : '../MutualRating/StudentMutualRatingViewWind.html',
							pageParam : {
								cid : api.pageParam.courseid,
								pid : api.pageParam.planid,
								stuid : MutualRatingdata.uid,
								id : MutualRatingdata.id,
								type : MutualRatingdata,
								sourceurl : window.location.pathname,
					            sourcetitle : document.title
							}
						});
					}
					break;
				case 7:
					{
						api.openWin({useWKWebView:true,
							name : 'SpontaneousMoments_Win',
							url : 'SpontaneousMoments_Win.html',
							pageParam : {
								cid : api.pageParam.courseid,
								pid : api.pageParam.planid,
								stuid : MutualRatingdata.uid,
								id : MutualRatingdata.id,
								type : MutualRatingdata,
								sourceurl : window.location.pathname,
					            sourcetitle : document.title
							}
						});
					}
					break;
			}
			getMessage();
		}
	</script>
</html>